#ifdef _WIN32
        #include "..\..\preproc.h"
        #include "..\..\list.h"
        #include <windows.h>
        char* slash = "\\";
#endif

#ifdef __linux__
        #include "../../preproc.h"
        #include "../../list.h"
        char* slash = "/";
#endif

#include "unistd.h"

void __declspec (dllexport) cd(int argc, string* args, gvars_t* gvars)
{
    if(!chdir(args[0]))
    {
        if(argc > 1)
        {
            if(!strcmp(args[1], "-to_obj"))
            {
                free(gvars->curr_dir);
                gvars->curr_dir = getcwd(NULL, 0);
                create_object(gvars, args[2], PTH_T, getcwd(NULL, 0));
                gvars->result = SUCCESS;
                return;
            }
            else
            {
                puts("Wrong flag!");
                free(gvars->curr_dir);
                gvars->curr_dir = getcwd(NULL, 0);
                gvars->result = ERROR;
                return;
            }
        }
        else
        {
            free(gvars->curr_dir);
            gvars->curr_dir = getcwd(NULL, 0);
            gvars->result = SUCCESS;
            return;
        }
    }
    else
    {
        puts("No such dirrectory!");
        gvars->result = ERROR;
        return;
    }
}
